<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
/**
 * Template Name: Category page
 *
 * A custom page template with sidebar based on a category.
 *
 * The "Template Name:" bit above allows this to be selectable
 * from a dropdown menu on the edit page screen.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

get_header(); ?>

		<div id="container">
			<div id="content" role="main">
			<?php
    			$cat_id = get_post_meta($post->ID, '_gl_page_cat', true) ;
    			$cat_name = get_cat_name($cat_id) ;
    			$cat_slug = gl_get_cat_slug($cat_id) ;

    			//  Set up the query arguments, in particular, pull the 
    			//  category id for the page and only show those posts.

    			$args = array(
        			'cat' => $cat_id
       			,'posts_per_page' => get_option( 'posts_per_page' )
       			,'paged' => $paged
    			) ;

                //  Create a new query instance and submit it.

                $wp_query = new WP_Query() ;
                $wp_query->query($args) ;
                $more = 0 ;
            ?>

			<?php
			/* Run the loop to output the page.
			 * If you want to overload this in a child theme then include a file
			 * called loop-page.php and that will be used instead.
			 */
			get_template_part( 'loop', 'category' );
			?>

			</div><!-- #content -->
		</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
